package edu.xaut.bookingsys.config;

import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Sa-Token的路由拦截器
     // 若鉴权不过以throw的形式抛出
        // TODO 关于鉴权的问题，后面来解决，当前全部放行
//        registry.addInterceptor(new SaRouteInterceptor((req,res,handler)->{
//                    SaRouter.match("/user/**",(r)->{return;});
//                        })).addPathPatterns("/**");
//        registry.addInterceptor(new SaRouteInterceptor())
//                .addPathPatterns("/**")
//                .excludePathPatterns("/user/login");
    }
}